/**
 * 
 */
package org.lora.biz.workflow.engines.bean;

import java.util.List;

import org.lora.biz.workflow.engines.entity.ProcessDefVer;
import org.lora.biz.workflow.engines.entity.ProcessDefinition;
import org.lora.util.ValidateUtil;

/**
 * <p>
 * 类名:ProcessDefinitionBean
 * </p>
 * 描述:流程定义实体<br>
 * 创建时间:2016年10月22日 下午6:20:38<br>
 * 
 * @author Bladnir@outlook.com<br>
 *         修改历史:<br>
 *         2016年10月22日 Bladnir 创建<br>
 */
public class ProcessDefinitionBean {

	private ProcessDefinition processDefinition;

	private List<ProcessDefVer> processDefVerList;

	/**
	 * 构造方法
	 * 
	 * @param processDefinition
	 * @param processDefVerList
	 */
	public ProcessDefinitionBean(ProcessDefinition processDefinition, List<ProcessDefVer> processDefVerList) {
		this.processDefinition = processDefinition;
		this.processDefVerList = processDefVerList;
	}

	public ProcessDefinition getProcessDefinition() {
		return processDefinition;
	}

	public void setProcessDefinition(ProcessDefinition processDefinition) {
		this.processDefinition = processDefinition;
	}

	public List<ProcessDefVer> getProcessDefVerList() {
		return processDefVerList;
	}

	public void setProcessDefVerList(List<ProcessDefVer> processDefVerList) {
		this.processDefVerList = processDefVerList;
	}

	/**
	 * 获取生效版本
	 * 
	 * @return
	 */
	public ProcessDefVer getEffectiveVer() {

		ProcessDefVer result = null;

		for (ProcessDefVer processDefVer : processDefVerList) {
			if (ValidateUtil.isEqual("Y", processDefVer.getEffective())) {
				result = processDefVer;
				break;
			}
		}

		return result;
	}

	/**
	 * 根据版本号 获取指定版本
	 * 
	 * @param version
	 * @return
	 */
	public ProcessDefVer getDefinitionVersion(String version) {
		ProcessDefVer result = null;

		for (ProcessDefVer processDefVer : processDefVerList) {
			if (ValidateUtil.isEqual(version, processDefVer.getVersion())) {
				result = processDefVer;
				break;
			}
		}

		return result;
	}

}
